<template>
	<view>
		<simple-toolbar :title="$t('pool.assetPool.assetPool')">
			<view class="update">
				<view class="button" @click="editAwardPool(1)">
					<image src="../../../static/create.png"></image>
					<text>{{ $t('pool.assetPool.newAssetPool') }}</text>
				</view>
			</view>
		</simple-toolbar>

		<view class="pad-base table">
			<nav-tab @change-current-tab="assetPool" @ready="assetPool" />
			
			<el-table :data="listData" style="width: 100%">
				<el-table-column align='center' prop="coin_name" :label="$t('wallet.wallet.coin')"></el-table-column>
				<!-- <el-table-column align='center' prop="public_key" :label="$t('pool.assetPool.public_key')"></el-table-column> -->
				<!-- <el-table-column align='center' prop="wallet" :label="$t('pool.assetPool.wallet')"></el-table-column> -->
				<el-table-column align='center' prop="current_tib" :label="$t('pool.assetPool.current_tib')"></el-table-column>
				<el-table-column align='center' prop="balance" :label="$t('pool.assetPool.balance')"></el-table-column>
				<el-table-column align='center' prop="rewards" :label="$t('pool.assetPool.rewards')"></el-table-column>
				<el-table-column align='center' prop="total_rewards" :label="$t('pool.assetPool.total_rewards')"></el-table-column>
				<el-table-column align='center' prop="record_time" :label="$t('pool.assetPool.record_time')"></el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	import {
		assetPool
	} from "../../../js_sdk/uni-admin/assetPool.js"

	export default {
		data() {
			return {
				listData: []
			}
		},
		methods: {
			editAwardPool(state, row) {
				if (state == 2) {
					return
				}
				uni.navigateTo({
					url: `./editAwardPool?state=${state}&data=${encodeURIComponent(JSON.stringify(row))}`
				})
			},
			async assetPool(data = { coin: 1 }) {
				this.data = data
				let res = await assetPool('get', data)
				this.listData = res.data
				this.listData.forEach(item => {
					item.balance = this.$utils.retain12(item.balance)
					item.rewards = this.$utils.retain12(item.rewards)
					item.total_rewards = this.$utils.retain12(item.total_rewards)
					item.record_time = this.$utils.formatDate(item.record_time)
				})
			}
		},
		onShow() {
			// this.assetPool(this.data)
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
